<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.1.1">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/avatar.jpg">
  <link rel="mask-icon" href="/images/avatar.jpg" color="#222">
  <meta name="msvalidate.01" content="4AF2328B2035748153A041B7EEF3D15C">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,300italic,400,400italic,700,700italic%7CLobster:300,300italic,400,400italic,700,700italic%7CPingFang+SC:300,300italic,400,400italic,700,700italic%7CRoboto+Mono:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.33/fancybox/fancybox.css" integrity="sha256-gkQVf8UKZgQ0HyuxL/VnacadJ+D2Kox2TCEBuNQg5+w=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"ethanliu6.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":true,"sidebar":{"position":"left","display":"always","padding":12,"offset":18},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":true,"color":"#222","save":"manual"},"mediumzoom":true,"lazyload":true,"pangu":false,"comments":{"style":"buttons","active":"changyan","storage":true,"lazyload":false,"nav":null,"activeClass":"changyan"},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":6,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="JavaSE进阶——Day05 该篇主要讲解Java中的泛型、数据结构、List集合和Set集合">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaSE进阶——Day05 泛型、数据结构、List集合、Set集合">
<meta property="og:url" content="http://ethanliu6.github.io/2024/04/19/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day05/Day05.%E6%B3%9B%E5%9E%8B%E3%80%81%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E3%80%81List%E9%9B%86%E5%90%88%E3%80%81Set%E9%9B%86%E5%90%88/index.html">
<meta property="og:site_name" content="&lt;font color&#x3D;&#39;white&#39; &gt;Ethan の Blog&lt;&#x2F;font&gt;">
<meta property="og:description" content="JavaSE进阶——Day05 该篇主要讲解Java中的泛型、数据结构、List集合和Set集合">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/EthanLiu6/ImgsForMe/blog_images/image-20240420173727772.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/EthanLiu6/ImgsForMe/blog_images/image-20240420193210344-20240420193554059.png">
<meta property="article:published_time" content="2024-04-18T16:00:00.000Z">
<meta property="article:modified_time" content="2024-04-20T14:36:11.932Z">
<meta property="article:author" content="Ethan Liu">
<meta property="article:tag" content="Java">
<meta property="article:tag" content="Java进阶">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/EthanLiu6/ImgsForMe/blog_images/image-20240420173727772.png">


<link rel="canonical" href="http://ethanliu6.github.io/2024/04/19/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day05/Day05.%E6%B3%9B%E5%9E%8B%E3%80%81%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E3%80%81List%E9%9B%86%E5%90%88%E3%80%81Set%E9%9B%86%E5%90%88/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://ethanliu6.github.io/2024/04/19/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day05/Day05.%E6%B3%9B%E5%9E%8B%E3%80%81%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E3%80%81List%E9%9B%86%E5%90%88%E3%80%81Set%E9%9B%86%E5%90%88/","path":"2024/04/19/JavaNotes/JavaSE进阶/day05/Day05.泛型、数据结构、List集合、Set集合/","title":"JavaSE进阶——Day05 泛型、数据结构、List集合、Set集合"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>JavaSE进阶——Day05 泛型、数据结构、List集合、Set集合 | <font color='white' >Ethan の Blog</font></title>
  








  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<style>.darkmode--activated{--body-bg-color:#282828;--content-bg-color:#333;--card-bg-color:#555;--text-color:#ccc;--blockquote-color:#bbb;--link-color:#ccc;--link-hover-color:#eee;--brand-color:#ddd;--brand-hover-color:#ddd;--table-row-odd-bg-color:#282828;--table-row-hover-bg-color:#363636;--menu-item-bg-color:#555;--btn-default-bg:#222;--btn-default-color:#ccc;--btn-default-border-color:#555;--btn-default-hover-bg:#666;--btn-default-hover-color:#ccc;--btn-default-hover-border-color:#666;--highlight-background:#282b2e;--highlight-foreground:#a9b7c6;--highlight-gutter-background:#34393d;--highlight-gutter-foreground:#9ca9b6}.darkmode--activated img{opacity:.75}.darkmode--activated img:hover{opacity:.9}.darkmode--activated code{color:#69dbdc;background:0 0}button.darkmode-toggle{z-index:9999}.darkmode-ignore,img{display:flex!important}.beian img{display:inline-block!important}</style></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title"><font color='white' >Ethan の Blog</font></p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description"><font color='#FDABC1' size=3>清醒的停留，胜过——盲目的前行</font></p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-关于我"><a href="/aboutme/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">18</span></a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">14</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">53</span></a></li><li class="menu-item menu-item-love"><a href="/categories/Love/" rel="section"><i class="fas fa-heart fa-fw"></i>Love</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%B3%9B%E5%9E%8B"><span class="nav-number">1.</span> <span class="nav-text"> 泛型 </span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%80%E4%B9%88%E6%98%AF%E6%B3%9B%E5%9E%8B"><span class="nav-number">1.1.</span> <span class="nav-text">什么是泛型？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%B3%9B%E5%9E%8B%E8%A7%A3%E5%86%B3%E7%A8%8B%E5%BA%8F%E4%B8%AD%E7%9A%84%E4%BB%80%E4%B9%88%E9%97%AE%E9%A2%98"><span class="nav-number">1.2.</span> <span class="nav-text">泛型解决程序中的什么问题？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%B3%9B%E5%9E%8B%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8"><span class="nav-number">1.3.</span> <span class="nav-text">泛型如何使用？</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%B3%9B%E5%9E%8B%E7%B1%BB"><span class="nav-number">1.3.1.</span> <span class="nav-text">泛型类</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%B3%9B%E5%9E%8B%E6%8E%A5%E5%8F%A3"><span class="nav-number">1.3.2.</span> <span class="nav-text">泛型接口</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%B3%9B%E5%9E%8B%E6%96%B9%E6%B3%95"><span class="nav-number">1.3.3.</span> <span class="nav-text">泛型方法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%B3%9B%E5%9E%8B%E6%A2%B3%E7%90%86"><span class="nav-number">1.3.4.</span> <span class="nav-text">泛型梳理</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%B3%9B%E5%9E%8B%E9%80%9A%E9%85%8D%E7%AC%A6"><span class="nav-number">1.3.5.</span> <span class="nav-text">泛型通配符</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%8F%97%E9%99%90%E6%B3%9B%E5%9E%8B"><span class="nav-number">1.3.6.</span> <span class="nav-text">受限泛型</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84"><span class="nav-number">2.</span> <span class="nav-text">数据结构 </span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E7%9A%84%E8%AE%A4%E8%AF%86"><span class="nav-number">2.1.</span> <span class="nav-text">数据结构的认识</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%A0%88"><span class="nav-number">2.2.</span> <span class="nav-text">栈</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%98%9F%E5%88%97"><span class="nav-number">2.3.</span> <span class="nav-text">队列</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%A0%91"><span class="nav-number">2.4.</span> <span class="nav-text">树</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%B9%B3%E8%A1%A1%E4%BA%8C%E5%8F%89%E6%A0%91"><span class="nav-number">2.5.</span> <span class="nav-text">平衡二叉树</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BA%A2%E9%BB%91%E6%A0%91"><span class="nav-number">2.6.</span> <span class="nav-text">红黑树</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#list%E9%9B%86%E5%90%88"><span class="nav-number">3.</span> <span class="nav-text">List集合</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#java%E8%AF%AD%E8%A8%80%E4%B8%AD%E9%9B%86%E5%90%88%E4%BD%93%E7%B3%BB%E5%88%92%E5%88%86"><span class="nav-number">3.1.</span> <span class="nav-text">Java语言中集合体系划分：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#java.util.collection%E9%9B%86%E5%90%88-%E6%98%AF%E4%B8%80%E4%B8%AA%E6%8E%A5%E5%8F%A3%E6%97%A0%E6%B3%95%E5%AE%9E%E4%BE%8B%E5%8C%96"><span class="nav-number">3.2.</span> <span class="nav-text">java.util.Collection集合：
是一个接口（无法实例化）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#java.util.list%E9%9B%86%E5%90%88"><span class="nav-number">3.3.</span> <span class="nav-text">java.util.List集合：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#arraylist%E9%9B%86%E5%90%88"><span class="nav-number">3.4.</span> <span class="nav-text">ArrayList集合：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%93%BE%E8%A1%A8%E7%BB%93%E6%9E%84"><span class="nav-number">3.5.</span> <span class="nav-text">链表结构：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#linkedlist%E9%9B%86%E5%90%88"><span class="nav-number">3.6.</span> <span class="nav-text">LinkedList集合：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#set%E9%9B%86%E5%90%88"><span class="nav-number">4.</span> <span class="nav-text">Set集合 </span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Ethan Liu"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">Ethan Liu</p>
  <div class="site-description" itemprop="description"><font color='#0000FF' size=1.5px>语言学 | NLP | Py | Java</font></div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">53</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">18</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2V0aGFubGl1Ng==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;ethanliu6"><i class="fab fa-github fa-fw"></i>GitHub</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="bWFpbHRvOmxpdWUyMzM2QGdtYWlsLmNvbQ==" title="E-Mail → mailto:liue2336@gmail.com"><i class="fa fa-envelope fa-fw"></i>E-Mail</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9zcGFjZS5iaWxpYmlsaS5jb20vMTMyNzA5OTk3Nw==" title="BiliBili → https:&#x2F;&#x2F;space.bilibili.com&#x2F;1327099977"><i class="fa-brands fa-bilibili fa-fw"></i>BiliBili</span>
      </span>
      <span class="links-of-author-item">
        <a href="/categories/Love/" title="Love → &#x2F;categories&#x2F;Love&#x2F;" rel="noopener me"><i class="fa fa-heart fa-fw"></i>Love</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://ethanliu6.github.io/2024/04/19/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day05/Day05.%E6%B3%9B%E5%9E%8B%E3%80%81%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E3%80%81List%E9%9B%86%E5%90%88%E3%80%81Set%E9%9B%86%E5%90%88/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="Ethan Liu">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="<font color='white' >Ethan の Blog</font>">
      <meta itemprop="description" content="<font color='#0000FF' size=1.5px>语言学 | NLP | Py | Java</font>">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="JavaSE进阶——Day05 泛型、数据结构、List集合、Set集合 | <font color='white' >Ethan の Blog</font>">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          JavaSE进阶——Day05 泛型、数据结构、List集合、Set集合<span class="exturl post-edit-link" data-url="aHR0cHM6Ly9naXRodWIuY29tL0V0aGFuTGl1Ni9ldGhhbmxpdTYuZ2l0aHViLmlvL3RyZWUvbWFzdGVyL19wb3N0cy9KYXZhTm90ZXMvSmF2YVNF6L+b6Zi2L2RheTA1L0RheTA1Luazm+Wei+OAgeaVsOaNrue7k+aehOOAgUxpc3Tpm4blkIjjgIFTZXTpm4blkIgubWQ=" title="编辑"><i class="fa fa-pen-nib"></i></span>
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-04-19 00:00:00" itemprop="dateCreated datePublished" datetime="2024-04-19T00:00:00+08:00">2024-04-19</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2024-04-20 22:36:11" itemprop="dateModified" datetime="2024-04-20T22:36:11+08:00">2024-04-20</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Java%E5%85%A8%E6%A0%88/" itemprop="url" rel="index"><span itemprop="name">Java全栈</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    <a title="JavaSE进阶——Day05 泛型、数据结构、List集合、Set集合" href="/2024/04/19/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day05/Day05.%E6%B3%9B%E5%9E%8B%E3%80%81%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E3%80%81List%E9%9B%86%E5%90%88%E3%80%81Set%E9%9B%86%E5%90%88/#SOHUCS" itemprop="discussionUrl">
      <span id="sourceId::651fabe1da25c92873f6ccfd090a12e9" class="cy_cmt_count" itemprop="commentCount"></span>
    </a>
  </span>
  
  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>1.1k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>4 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><blockquote class="blockquote-center">
<p>JavaSE进阶——Day05
该篇主要讲解Java中的泛型、数据结构、List集合和Set集合</p>

</blockquote>
<span id="more"></span>
<h2 id="泛型"><span id="inline-blue"> 泛型 </span></h2>
<h3 id="什么是泛型">什么是泛型？</h3>
<p>是一种或类型参数，可以来设置存储数据类型</p>
<h3 id="泛型解决程序中的什么问题">泛型解决程序中的什么问题？</h3>
<div class="note primary"><ul>
<li><p>限制集和中的数据类型</p></li>
<li><p>泛型是使用在代码编写时的一种技术方式（编译期技术）</p></li>
<li><p>泛型使用后不用再进行数据类型的强转</p></li>
<li><p>泛型在程序运行后就会擦除</p></li>
</ul>
</div>
<h3 id="泛型如何使用">泛型如何使用？</h3>
<h4 id="泛型类">泛型类</h4>
<div class="note primary"><p>当不确定属类中某个属性类型时，可以使用泛型表示</p>
</div>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> class 类名&lt;E&gt;&#123; <span class="comment">/* E就是泛型名 */</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 当不确定属类中某个属性类型时，可以使用泛型表示</span></span><br><span class="line"><span class="keyword">public</span> class 泛型类&lt;T&gt;&#123;</span><br><span class="line">  <span class="keyword">private</span> T 变量;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 在创建泛型类对象时，明确类型</span></span><br><span class="line"> 泛型类&lt;Integer&gt; 对象引用 = <span class="keyword">new</span> 泛型类&lt;Integer&gt;(); <span class="comment">//泛型类中成员变量的类型为：Integer</span></span><br><span class="line"> 泛型类&lt;String&gt; 对象引用 = <span class="keyword">new</span> 泛型类&lt;String&gt;(); <span class="comment">//泛型类中成员变量的类型为：String</span></span><br></pre></td></tr></table></figure>
<p>代码：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> io.github.ethanliu6.genericity;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Author</span> EthanLiu 16693226842@163.com</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Date</span> 2024/4/19 18:32</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Project</span> JavaCode_SE_Advance</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Theme</span> 泛型</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Demo01</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        GenericityClass&lt;String&gt; gc1 = <span class="keyword">new</span> <span class="title class_">GenericityClass</span>&lt;&gt;(); <span class="comment">//5版本后可以在后面不添加类型</span></span><br><span class="line">        gc1.setObj(<span class="string">&quot;Ethan Love Qiu&quot;</span>);</span><br><span class="line">        System.out.println(gc1.getObj());</span><br><span class="line"></span><br><span class="line">        GenericityClass&lt;Integer&gt; gc2 = <span class="keyword">new</span> <span class="title class_">GenericityClass</span>&lt;&gt;();</span><br><span class="line">        gc2.setObj(<span class="number">8888</span>);</span><br><span class="line">        System.out.println(gc2.getObj());</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 当不确定属类中某个属性类型时，可以使用泛型表示</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">GenericityClass</span>&lt;T&gt; &#123;</span><br><span class="line">    <span class="keyword">private</span> T obj;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> T <span class="title function_">getObj</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> obj;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setObj</span><span class="params">(T obj)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.obj = obj;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="泛型接口">泛型接口</h4>
<div class="note primary"><p>当不确定接口中某个方法参数使用什么类型或者方法返回值类型时，可以使用泛型表示</p>
</div>
<p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> interface 泛型接口&lt;E&gt;&#123; <span class="comment">/* E就是泛型名 */</span></span><br><span class="line">  <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">(E e)</span>&#123;</span><br><span class="line">    </span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 当不确定接口中某个方法参数使用什么类型或者方法返回值类型时，可以使用泛型表示</span></span><br></pre></td></tr></table></figure></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 情况1：在子类编写时，指定接口上泛型的具体类型</span></span><br><span class="line"><span class="keyword">public</span> class 子类 implements 泛型接口&lt;String&gt; &#123;</span><br><span class="line">  <span class="comment">//方法重写</span></span><br><span class="line">  <span class="meta">@Override</span></span><br><span class="line">  <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">(String e)</span> <span class="comment">/* T --&gt; String */</span> &#123;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 情况2：在子类编写时，没有指定接口上泛型的具体类型，意味着：子类也使用了跟泛型接口同样的泛型（子类 --&gt; 泛型类）</span></span><br><span class="line"><span class="keyword">public</span> class 子类&lt;E&gt; implements 泛型接口&lt;E&gt; &#123;</span><br><span class="line">  <span class="comment">//方法重写</span></span><br><span class="line">  <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">(E e)</span>&#123;</span><br><span class="line">    </span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">注意：在创建子类对象时，指定类型</span><br><span class="line">  子类&lt;Integer&gt; 子类引用名 = <span class="keyword">new</span> 子类&lt;&gt;();</span><br></pre></td></tr></table></figure>
<h4 id="泛型方法">泛型方法</h4>
<div class="note primary"><p>当前类没有声明为泛型类，当方法不知道参数类型或者返回值类型时，使用泛型方法</p>
</div>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//语法格式</span></span><br><span class="line">修饰符号 &lt;泛型&gt; 返回值类型 方法名(&lt;参数泛型&gt; 参数<span class="number">1</span>, ……)&#123;</span><br><span class="line">  <span class="comment">//方法体</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span>  &lt;T&gt; method(&lt;E&gt; param)&#123;</span><br><span class="line">  <span class="comment">//……</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//当调用方法时， 传入的参数类型就是泛型类型</span></span><br></pre></td></tr></table></figure>
<hr>
<h4 id="泛型梳理">泛型梳理</h4>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line">基础泛型的定义：</span><br><span class="line"><span class="number">1</span>、泛型类</span><br><span class="line"><span class="number">2</span>、泛型接口</span><br><span class="line"><span class="number">3</span>、泛型方法</span><br><span class="line"></span><br><span class="line">问题：开发时选择哪个泛型定义？</span><br><span class="line">第<span class="number">1</span>，先明确要定义的是接口还是类</span><br><span class="line">     当类中的成员变量，在不确定具体使用哪种类型时，可以使用：泛型 表示类型</span><br><span class="line">     当接口中方法，在不确定方法参数类型或方法返回值类型时，可以使用：泛型 表示类型</span><br><span class="line">第<span class="number">2</span>，在编写工具类时，工具类中的方法参数或方法返回值，不确定具体类型， 可以使用： 泛型</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">问题：泛型定义的语法</span><br><span class="line"><span class="comment">//泛型类</span></span><br><span class="line"><span class="keyword">public</span> class 类名&lt;T,E,X,Y&gt;&#123;</span><br><span class="line">    <span class="keyword">private</span> T name;</span><br><span class="line">    <span class="keyword">private</span> E a;</span><br><span class="line">    <span class="keyword">private</span> X n;</span><br><span class="line">    <span class="keyword">private</span> Y m;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> 类名(T name , E a , X n ,Y m)&#123;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">new</span> 类名&lt;String,Integer,Double,Student&gt;();</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">//泛型接口</span></span><br><span class="line"><span class="keyword">public</span> interface 接口名&lt;T,E&gt;&#123;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//泛型方法</span></span><br><span class="line"><span class="keyword">public</span> &lt;T&gt; T 方法名(T 参数名)&#123;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">问题： 怎么明确泛型指定的具体类型（指定泛型上的类型）</span><br><span class="line"><span class="comment">//泛型类： 在创建对象时，指定泛型类型</span></span><br><span class="line">类名&lt;String&gt; 对象 = <span class="keyword">new</span> 类名&lt;&gt;();</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">//泛型接口： 1.在子类实现接口时，明确指定了泛型类型      2.子类继承接口上的泛型（子类变为泛型类）</span></span><br><span class="line">interface 接口&lt;T&gt;&#123;</span><br><span class="line">   <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">(T n)</span>;</span><br><span class="line">   <span class="keyword">public</span> T <span class="title function_">get</span><span class="params">()</span>;</span><br><span class="line">&#125;</span><br><span class="line">class 子类 implements 接口&lt;Integer&gt;&#123;</span><br><span class="line">   <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">(Integer n)</span>&#123;</span><br><span class="line">   &#125;</span><br><span class="line">   <span class="keyword">public</span> Integer <span class="title function_">get</span><span class="params">()</span>&#123;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">class 子类&lt;T&gt; implements 接口&lt;T&gt;&#123;</span><br><span class="line">   <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">(T n)</span>&#123;</span><br><span class="line">   &#125;</span><br><span class="line">   <span class="keyword">public</span> T <span class="title function_">get</span><span class="params">()</span>&#123;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//泛型方法：</span></span><br><span class="line"><span class="keyword">public</span> class 类&#123;</span><br><span class="line"></span><br><span class="line">   <span class="keyword">public</span> &lt;T&gt; T <span class="title function_">getInstance</span><span class="params">(T param)</span>&#123;</span><br><span class="line">   &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"><span class="type">Student</span> <span class="variable">stu</span> <span class="operator">=</span> 类对象.getInstance( <span class="keyword">new</span> <span class="title class_">Student</span>() )</span><br></pre></td></tr></table></figure>
<h4 id="泛型通配符">泛型通配符</h4>
<ul>
<li>泛型通配符：<code>&lt;?&gt;</code>（任意类型）</li>
<li>通常在开发中，<code>?</code>与泛型的上下限一起使用</li>
</ul>
<h4 id="受限泛型">受限泛型</h4>
<p>泛型下限：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//指定的泛型中的最小类型</span></span><br><span class="line">&lt;? <span class="built_in">super</span> 最小类型&gt;</span><br><span class="line">  </span><br><span class="line">?可以是该最小类型</span><br><span class="line">?也可以是该类型的父类型</span><br></pre></td></tr></table></figure>
<p>泛型上限：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//指定泛型中的最大类型</span></span><br><span class="line">&lt;? extends 最大类型&gt;</span><br><span class="line"></span><br><span class="line">?可以是该最大类型</span><br><span class="line">?也可以是该最大类型的子类型</span><br></pre></td></tr></table></figure>
<p>例如：</p>
<p><img data-src="https://cdn.jsdelivr.net/gh/EthanLiu6/ImgsForMe/blog_images/image-20240420173727772.png" alt="image-20240420173727772" style="zoom: 67%;"></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> io.github.ethanliu6.genericity.demo03;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.ArrayList;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Author</span> EthanLiu 16693226842@163.com</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Date</span> 2024/4/20 17:21</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Project</span> JavaCode_SE_Advance</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Theme</span> 泛型限制</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Test2</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        ArrayList&lt;Person&gt; people = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;&gt;();</span><br><span class="line">        people.add(<span class="keyword">new</span> <span class="title class_">Student</span>(<span class="number">126</span>, <span class="string">&quot;202234004026&quot;</span>));</span><br><span class="line">        people.add(<span class="keyword">new</span> <span class="title class_">Worker</span>());</span><br><span class="line">        show1(people);</span><br><span class="line">        show2(people);</span><br><span class="line"></span><br><span class="line">        System.out.println(<span class="string">&quot;\n+++++++++++++++++\n&quot;</span>);</span><br><span class="line">        ArrayList&lt;Worker&gt; workers = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;&gt;();</span><br><span class="line">        workers.add(<span class="keyword">new</span> <span class="title class_">Worker</span>());</span><br><span class="line">        <span class="comment">// workers.add(new Student(123, &quot;23453456&quot;)); 泛型限制</span></span><br><span class="line">        show1(workers);</span><br><span class="line">        <span class="comment">// show2(workers); 编译出错,泛型下限受限</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">show1</span><span class="params">(ArrayList&lt;? extends Person&gt; people)</span> &#123;</span><br><span class="line">        System.out.println(<span class="string">&quot;show1是泛型上限&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">show2</span><span class="params">(ArrayList&lt;? <span class="built_in">super</span> Student&gt; E)</span>&#123;</span><br><span class="line">        System.out.println(<span class="string">&quot;show2是泛型下限&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="数据结构"><span id="inline-blue">数据结构 </span></h2>
<p><strong>这里只是简单的学习数据结构，并非408中的系统性数据结构</strong></p>
<h3 id="数据结构的认识">数据结构的认识</h3>
<p>数据结构：数据存储时的一种排列方式</p>
<p>类型：</p>
<div class="note success"><ul>
<li><p>栈（先进后出）</p></li>
<li><p>队列（先进先出）//数组就是这种方式</p>
<p>数组结构：</p>
<ol type="1">
<li><p>数组在内存中的体现是一块连续存储数据的空间</p></li>
<li><p>特点是查询快、增删元素慢</p></li>
<li><p><code>ArrayList</code>集合底层就是使用：数组结构</p></li>
</ol></li>
<li><p>链表</p></li>
<li><p>哈希表</p></li>
<li><p>树</p>
<ul>
<li>二叉树</li>
<li>平衡二叉树</li>
<li>红黑树</li>
<li>……</li>
</ul></li>
</ul>
</div>
<h3 id="栈">栈</h3>
<h3 id="队列">队列</h3>
<h3 id="树">树</h3>
<h3 id="平衡二叉树">平衡二叉树</h3>
<h3 id="红黑树">红黑树</h3>
<h2 id="list集合"><span id="inline-blue">List集合</span></h2>
<h3 id="java语言中集合体系划分">Java语言中集合体系划分：</h3>
<ul>
<li>Collection (接口)</li>
<li>Map （接口）</li>
</ul>
<h3 id="java.util.collection集合-是一个接口无法实例化">java.util.Collection集合：
是一个接口（无法实例化）</h3>
<ul>
<li>java.util.List集合（接口）
<ul>
<li>常用子类：ArrayList 、 LinkedList</li>
</ul></li>
<li>java.util.Set集合（接口）</li>
</ul>
<figure>
<img data-src="https://cdn.jsdelivr.net/gh/EthanLiu6/ImgsForMe/blog_images/image-20240420193210344-20240420193554059.png" alt="image-20240420193210344">
<figcaption aria-hidden="true">image-20240420193210344</figcaption>
</figure>
<h3 id="java.util.list集合">java.util.List集合：</h3>
<ul>
<li>带有索引</li>
<li>存储的元素的顺序和获取元素的顺序一致</li>
<li>可以存储重复元素</li>
</ul>
<p>因为List集合可以使用索引，故围绕着索引，设计很多API方法：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//添加元素</span></span><br><span class="line">List集合.add( 索引 ， 元素值) <span class="comment">//向List集合中指定索引位置上，添加元素</span></span><br><span class="line">                           <span class="comment">//如指定索引位置上已有索引，会自动后向移动</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//修改元素</span></span><br><span class="line">List集合.set( 索引 ， 元素值) <span class="comment">//修改List集合中指定索引位置上的元素值    </span></span><br><span class="line"></span><br><span class="line"><span class="comment">//删除元素</span></span><br><span class="line">List集合.remove(索引) <span class="comment">//删除List集合中指定索引位置上的元素值    </span></span><br><span class="line"></span><br><span class="line"><span class="comment">//获取元素</span></span><br><span class="line">List集合.get(索引);</span><br></pre></td></tr></table></figure>
<h3 id="arraylist集合">ArrayList集合：</h3>
<ul>
<li>实现List接口（List接口中的所有功能都有）</li>
<li>底层使用：数组
<ul>
<li>查询快 、 增删慢</li>
</ul></li>
</ul>
<h3 id="链表结构">链表结构：</h3>
<ul>
<li>在内存中是使用==节点==来存储数据
<ul>
<li>节点 = 数据 + 地址</li>
</ul></li>
<li>链表：有头、有尾</li>
<li>分类：
<ol type="1">
<li>单向链表：只能从头到尾</li>
<li>双向链表：可以从头到尾，也可以从尾到头 （提高查询效率）</li>
</ol></li>
<li>代表集合类：LinkedList</li>
</ul>
<h3 id="linkedlist集合">LinkedList集合：</h3>
<ul>
<li><p>实现List接口</p></li>
<li><p>底层使用：双向链表（有头有尾）</p>
<ul>
<li>增删快 、 查询慢</li>
</ul></li>
<li><p>特有方法都围绕着链表头和尾设计</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//添加元素</span></span><br><span class="line">addFirst( 元素 ) <span class="comment">//把元素添加到链表头部</span></span><br><span class="line">addLast( 元素 )  <span class="comment">//把元素添加到链表尾部    </span></span><br><span class="line"></span><br><span class="line"><span class="comment">//删除元素</span></span><br><span class="line">removeFirst()</span><br><span class="line">removeLast()    </span><br><span class="line"></span><br><span class="line"><span class="comment">//获取元素</span></span><br><span class="line">getFirst()</span><br><span class="line">getLast()</span><br></pre></td></tr></table></figure></li>
</ul>
<h2 id="set集合"><span id="inline-blue">Set集合 </span></h2>
<p>Collection集合</p>
<ul>
<li><p>List集合</p>
<ol type="1">
<li>有索引</li>
<li>存取元素有序</li>
<li>可能存储重复元素</li>
</ol></li>
<li><p>Set集合</p>
<ol type="1">
<li>没有索引</li>
<li>存取元素不保证顺序</li>
<li>不允许存储重复元素</li>
</ol></li>
</ul>
<p>Set集合中方法全部来自Collection集合</p>
<p>Set集合的子类：</p>
<ul>
<li><p>HashSet集合</p>
<ul>
<li><p>特点：</p>
<ol type="1">
<li>没有索引</li>
<li>存取元素不保证顺序</li>
<li>不能存储重复元素</li>
</ol></li>
<li><p>底层使用：哈希表结构</p></li>
</ul></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> io.github.ethanliu6.set;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.HashSet;</span><br><span class="line"><span class="keyword">import</span> java.util.Objects;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Author</span> EthanLiu 16693226842@163.com</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Date</span> 2024/4/20 20:26</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Project</span> JavaCode_SE_Advance</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Theme</span> HashSet</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">HashSetDemo1</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        HashSet&lt;Person&gt; peopleSet = <span class="keyword">new</span> <span class="title class_">HashSet</span>&lt;&gt;();</span><br><span class="line"></span><br><span class="line">        <span class="comment">//向集合中添加Person对象</span></span><br><span class="line">        peopleSet.add(<span class="keyword">new</span> <span class="title class_">Person</span>(<span class="string">&quot;Qiu Zhu&quot;</span>, <span class="number">21</span>)); <span class="comment">//匿名对象</span></span><br><span class="line">        peopleSet.add(<span class="keyword">new</span> <span class="title class_">Person</span>(<span class="string">&quot;Ethan Liu&quot;</span>, <span class="number">21</span>));</span><br><span class="line">        peopleSet.add(<span class="keyword">new</span> <span class="title class_">Person</span>(<span class="string">&quot;Qiu Zhu&quot;</span>, <span class="number">21</span>)); <span class="comment">//输出发现并没有去重,需要重写hashCode并用equals方法</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="comment">//使用增强for来遍历(迭代器)</span></span><br><span class="line">        <span class="keyword">for</span> (Person person : peopleSet) &#123;</span><br><span class="line">            System.out.println(person);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Person</span> &#123;</span><br><span class="line">    <span class="keyword">private</span> String name;</span><br><span class="line">    <span class="keyword">private</span> <span class="type">int</span> age;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="keyword">public</span> <span class="type">boolean</span> <span class="title function_">equals</span><span class="params">(Object o)</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (<span class="built_in">this</span> == o) <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">        <span class="keyword">if</span> (o == <span class="literal">null</span> || getClass() != o.getClass()) <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">        <span class="type">Person</span> <span class="variable">person</span> <span class="operator">=</span> (Person) o;</span><br><span class="line">        <span class="keyword">return</span> age == person.age &amp;&amp; Objects.equals(name, person.name);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="keyword">public</span> <span class="type">int</span> <span class="title function_">hashCode</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> Objects.hash(name, age);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">toString</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;Person&#123;&quot;</span> +</span><br><span class="line">                <span class="string">&quot;name=&#x27;&quot;</span> + name + <span class="string">&#x27;\&#x27;&#x27;</span> +</span><br><span class="line">                <span class="string">&quot;, age=&quot;</span> + age +</span><br><span class="line">                <span class="string">&#x27;&#125;&#x27;</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">getName</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> name;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setName</span><span class="params">(String name)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.name = name;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="type">int</span> <span class="title function_">getAge</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> age;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setAge</span><span class="params">(<span class="type">int</span> age)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.age = age;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="title function_">Person</span><span class="params">(String name, <span class="type">int</span> age)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.name = name;</span><br><span class="line">        <span class="built_in">this</span>.age = age;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="title function_">Person</span><span class="params">()</span> &#123;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>LinkedHashSet集合</li>
<li>TreeSet集合</li>
</ul>
<p>哈希表数据结构：</p>
<ul>
<li><p>底层是使用大小为16的数组+链表组成的存储方式</p></li>
<li><p>哈希表存储数据的方式 （ 借助：哈希值[存储位置] ）</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">拿要存储的元素，结合哈希算法， 计算出哈希值(存储位置) // 调用：  元素.hashCode()</span><br><span class="line"></span><br><span class="line">判断 ： 计算出的存储位置上是否有元素存在    </span><br><span class="line">       情况1 ： 没有元素存在     =&gt;  直接存储</span><br><span class="line">       情况2 ： 已有元素存在</span><br><span class="line">               拿要存储的元素 和 已经存在的元素 进行比较（比较内容是否相同） //元素.equals() </span><br><span class="line">               相同： （重复元素）  =&gt;  不存储</span><br><span class="line">               不相同： （不重复元素）</span><br><span class="line">                      再次拿当前存储空间作为算法因子，再次进行哈希算法，计算新的存储空间</span><br><span class="line">                      </span><br><span class="line"></span><br></pre></td></tr></table></figure></li>
<li><p>从JDK1.8开始，哈希表底层进行优化，使用：数组+链表/红黑树</p>
<ul>
<li>从链表 =&gt; 红黑树时机： 当链表的长度&gt;8，自动
把链表转换为红黑树</li>
</ul></li>
</ul>
<p>Set集合：</p>
<ul>
<li><p>HashSet</p>
<ul>
<li>底层：哈希表结构</li>
<li>特点：
<ol type="1">
<li>不能存储重复元素</li>
<li>没有索引</li>
<li>存取元素顺序不保证一致</li>
</ol></li>
</ul></li>
<li><p>LinkedHashSet</p>
<ul>
<li><p>特点：</p>
<ol type="1">
<li>没有索引</li>
<li>不能存储重复元素</li>
<li>存取元素顺序一致</li>
</ol></li>
<li><p>底层：哈希表+链表（保证存储元素的顺序）</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> io.github.ethanliu6.set;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.LinkedHashSet;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Author</span> EthanLiu 16693226842@163.com</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Date</span> 2024/4/20 21:10</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Project</span> JavaCode_SE_Advance</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Theme</span> LinkedHashSet</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">LinkedHashSetDemo1</span> &#123;</span><br><span class="line">    <span class="comment">//验证: 获取元素顺序</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">//创建集合对象</span></span><br><span class="line">        LinkedHashSet&lt;String&gt; linkedHashSet = <span class="keyword">new</span> <span class="title class_">LinkedHashSet</span>&lt;&gt;();</span><br><span class="line"></span><br><span class="line">        linkedHashSet.add(<span class="string">&quot;Qiu&quot;</span>);</span><br><span class="line">        linkedHashSet.add(<span class="string">&quot;Ethan&quot;</span>);</span><br><span class="line">        linkedHashSet.add(<span class="string">&quot;Qiu&quot;</span>);</span><br><span class="line">        linkedHashSet.add(<span class="string">&quot;Liu&quot;</span>);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">for</span> (String s : linkedHashSet) &#123;</span><br><span class="line">            System.out.println(s); <span class="comment">//有序的</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
</ul></li>
<li><p>TreeSet（下一篇文章）</p></li>
</ul>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="reward-container">
  <div>请我一杯咖啡吧！</div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="/images/wChat.png" alt="Ethan Liu 微信">
        <span>微信</span>
      </div>

  </div>
</div>

          

<div class="post-copyright">
<ul>
  <li class="post-copyright-author">
      <strong>本文作者： </strong>Ethan Liu
  </li>
  <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="http://ethanliu6.github.io/2024/04/19/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day05/Day05.%E6%B3%9B%E5%9E%8B%E3%80%81%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E3%80%81List%E9%9B%86%E5%90%88%E3%80%81Set%E9%9B%86%E5%90%88/" title="JavaSE进阶——Day05 泛型、数据结构、List集合、Set集合">http://ethanliu6.github.io/2024/04/19/JavaNotes/JavaSE进阶/day05/Day05.泛型、数据结构、List集合、Set集合/</a>
  </li>
  <li class="post-copyright-license">
      <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzQuMC8="><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</span> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


          <div class="post-tags">
              <a href="/tags/Java/" rel="tag"><i class="fa fa-tag"></i> Java</a>
              <a href="/tags/Java%E8%BF%9B%E9%98%B6/" rel="tag"><i class="fa fa-tag"></i> Java进阶</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2024/04/14/Academic/econometrics/%E5%9B%A0%E6%9E%9C%E6%8E%A8%E7%90%86%E5%9C%A8python%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8/" rel="prev" title="Causal Inference In Python">
                  <i class="fa fa-angle-left"></i> Causal Inference In Python
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2024/04/20/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day06/2024-04-19-JavaSE%E8%BF%9B%E9%98%B6%E2%80%94%E2%80%94Day06-%E6%8E%92%E5%BA%8F%E6%9F%A5%E6%89%BE%E7%AE%97%E6%B3%95%E3%80%81Map%E9%9B%86%E5%90%88%E3%80%81%E9%9B%86%E5%90%88%E5%B5%8C%E5%A5%97%E3%80%81%E6%96%97%E5%9C%B0%E4%B8%BB%E6%A1%88%E4%BE%8B/" rel="next" title="JavaSE进阶——Day06 TreeSet、排序查找算法、Map集合、集合嵌套">
                  JavaSE进阶——Day06 TreeSet、排序查找算法、Map集合、集合嵌套 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






    <div class="comments" id="SOHUCS" sid="651fabe1da25c92873f6ccfd090a12e9"></div>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2023-2024 – 
    <span itemprop="copyrightYear">2024</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">Is Ethan's</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
    <span title="站点总字数">113k</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">6:51</span>
  </span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>

    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

  <span class="exturl github-corner" data-url="aHR0cHM6Ly9naXRodWIuY29tL0V0aGFuTGl1Ni8=" title="在 GitHub 上关注我" aria-label="在 GitHub 上关注我"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></span>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.33/fancybox/fancybox.umd.js" integrity="sha256-+2+qOqR8CKoHh/AsVR9k2qaDBKWjYNC2nozhYmv5j9k=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/medium-zoom/1.1.0/medium-zoom.min.js" integrity="sha256-ZgMyDAIYDYGxbcpJcfUnYwNevG/xi9OHKaR/8GK+jWc=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/bookmark.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>

  <script class="next-config" data-name="pdf" type="application/json">{"object_url":{"url":"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.2.12/pdfobject.min.js","integrity":"sha256-g2xji1rlE3KsGVClvuxTbcR0Kn2+wtQADSff2Tbb4zA="},"url":"/lib/pdf/web/viewer.html"}</script>
  <script src="/js/third-party/tags/pdf.js"></script>



  <script src="/js/third-party/fancybox.js"></script>



  
  <script data-pjax async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"all","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


  <script src="https://cdnjs.cloudflare.com/ajax/libs/quicklink/2.3.0/quicklink.umd.js" integrity="sha256-yvJQOINiH9fWemHn0vCA5lsHWJaHs6/ZmO+1Ft04SvM=" crossorigin="anonymous"></script>
  <script class="next-config" data-name="quicklink" type="application/json">{"enable":true,"home":true,"archive":true,"delay":true,"timeout":3000,"priority":true,"url":"http://ethanliu6.github.io/2024/04/19/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day05/Day05.%E6%B3%9B%E5%9E%8B%E3%80%81%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E3%80%81List%E9%9B%86%E5%90%88%E3%80%81Set%E9%9B%86%E5%90%88/"}</script>
  <script src="/js/third-party/quicklink.js"></script>
<script class="next-config" data-name="changyan" type="application/json">{"enable":true,"appid":"cyxf6tytI","appkey":"90987f30c4b5248baad5a04c7a6abfe1","count":true}</script>
<script src="/js/third-party/comments/changyan.js"></script>

</body>
</html>
